import { createRouter, createWebHistory } from "vue-router";
import home from "../pages/home.vue"
import news from "../pages/news.vue"
import about from "../pages/about.vue"
import NewsSon from "../pages/NewsSon.vue"
// 创建路由器
const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      redirect: "/home" // 可选的默认路由重定向
    },
    {
      name: "homeName",
      path: "/home",
      component: home
    },
    {
      name: "newsName",
      path: "/news",
      component: news,
      children: [
        {
          name: "newsson",
          path: "newsson",
          component: NewsSon,
          //props第一种写法，只能用于params传参，将path中的参数传递
          // props: true

          //props第二种写法，能用于query和params传参
          // props(route) {
          //   //传递一个route，里面含有query和params等等
          //   return route.query
          // }

          //props第三种写法
          //直接传递参数，在页面上使用
          props: {
            a: 1,
            b: 2,
            c: 3
          }

        }
      ]
    },
    {
      name: "aboutName",
      path: "/about",
      component: about
    },
  ]
})
export default router